// import QtQuick 1.0 // to target S60 5th Edition or Maemo 5
import QtQuick 1.1

Rectangle {
    width: 480
    height: 480
    focus: true
    color: "#111111"

    property real start_opacity: 0.0

    property int msg_number: 0

    signal finish


    function start(number){
        msg_number = number;
        _timer.start();
    }


    Timer{
        id: _timer
        interval: 500
        repeat: true
        onTriggered: {
            switch(msg_number){
            case 0:
                _msgAnim1.start();
                break;
            case 1:
                _msgAnim2.start();
                break;
            case 2:
                _msgAnim3.start();
                break;

            case 10:
                _msgAnim10.start();
                msg_number++;
                break;
            case 11:
                _msgAnim11.start();
                msg_number++;
                break;
            case 12:
                _msgAnim12.start();
                msg_number++;
                break;
            case 13:
                _msgAnim13.start();
                msg_number++;
                break;
            case 14:
                _msgAnim14.start();
                msg_number++;
                break;
            case 15:
                _msgAnim15.start();
                msg_number++;
                break;
            case 16:
                _msgAnim16.start();
                msg_number++;
                break;
            case 17:
                _msgAnim17.start();
                msg_number++;
                break;
            case 18:
                _msgAnim18.start();
                msg_number++;
                break;
            case 19:
                _msgAnim19.start();
                msg_number++;
                break;
            case 20:
                _msgAnim20.start();
                msg_number++;
                break;
            case 21:
                _msgAnim21.start();
                msg_number++;
                break;
            case 22:
                _msgAnim22.start();
                msg_number++;
                break;
            case 23:
                _msgAnim23.start();
                break;
            case 24:
                _msgAnim24.start();
                break;


            case 100:
            default:
                _timer.stop();
                finish();
                break;
            }
            msg_number = msg_number;    //switchのバグ対策
        }
    }

    function pressed(key){
        switch(key){
        case Qt.Key_Enter:
        case Qt.Key_Return:
        case Qt.Key_Space:
            if(msg_number > 0){
                _timer.stop();
                finish();
            }
            break;
        default:
            break;
        }
//        console.debug("key");
    }
    function released(key){

    }
    Keys.onPressed: {
        pressed(event.key);
    }

    Text{
        anchors.right: parent.right
        anchors.bottom: parent.bottom
        color: "#555555"
        text: "skip(press enter) >>"
        MouseArea{
            anchors.fill: parent
            onClicked: {
                _timer.stop();
                finish();
            }
        }
    }

    Image{
        id: _msg1
        anchors.centerIn: parent
        opacity: start_opacity
        source: "./images/eyecatch_msg_1.png"
        PrologueMsgAnim{
            id: _msgAnim1
            target: _msg1
            onFinish: {
                msg_number = 100;
            }
        }
    }
    Image{
        id: _msg2
        anchors.centerIn: parent
        opacity: start_opacity
        source: "./images/eyecatch_msg_2.png"
        PrologueMsgAnim{
            id: _msgAnim2
            target: _msg2
            onFinish: {
                msg_number = 100;
            }
        }
    }
    Image{
        id: _msg3
        anchors.centerIn: parent
        opacity: start_opacity
        source: "./images/eyecatch_msg_3.png"
        PrologueMsgAnim{
            id: _msgAnim3
            target: _msg3
            onFinish: {
                msg_number = 100;
            }
        }
    }





    Image{
        id: _msg10
        x: 229
        y: 18
        opacity: start_opacity
        source: "./images/eyecatch_msg_10.png"
        PrologueMsgAnim{
            id: _msgAnim10
            target: _msg10
        }
    }
    Image{
        id: _msg11
        x: 21
        y: 111
        opacity: start_opacity
        source: "./images/eyecatch_msg_11.png"
        PrologueMsgAnim{
            id: _msgAnim11
            target: _msg11
        }
    }
    Image{
        id: _msg12
        x: 193
        y: 206
        opacity: start_opacity
        source: "./images/eyecatch_msg_12.png"
        PrologueMsgAnim{
            id: _msgAnim12
            target: _msg12
        }
    }
    Image{
        id: _msg13
        x: 21
        y: 333
        opacity: start_opacity
        source: "./images/eyecatch_msg_13.png"
        PrologueMsgAnim{
            id: _msgAnim13
            target: _msg13
        }
    }
    Image{
        id: _msg14
        x: 188
        y: 380
        opacity: start_opacity
        source: "./images/eyecatch_msg_14.png"
        PrologueMsgAnim{
            id: _msgAnim14
            target: _msg14
        }
    }
    Image{
        id: _msg15
        x: 59
        y: 133
        opacity: start_opacity
        source: "./images/eyecatch_msg_15.png"
        PrologueMsgAnim{
            id: _msgAnim15
            target: _msg15
        }
    }
    Image{
        id: _msg16
        x: 17
        y: 183
        opacity: start_opacity
        source: "./images/eyecatch_msg_16.png"
        PrologueMsgAnim{
            id: _msgAnim16
            target: _msg16
        }
    }
    Image{
        id: _msg17
        x: 78
        y: 309
        opacity: start_opacity
        source: "./images/eyecatch_msg_17.png"
        PrologueMsgAnim{
            id: _msgAnim17
            target: _msg17
        }
    }
    Image{
        id: _msg18
        x: 21
        y: 89
        opacity: start_opacity
        source: "./images/eyecatch_msg_18.png"
        PrologueMsgAnim{
            id: _msgAnim18
            target: _msg18
        }
    }
    Image{
        id: _msg19
        x: 162
        y: 256
        opacity: start_opacity
        source: "./images/eyecatch_msg_19.png"
        PrologueMsgAnim{
            id: _msgAnim19
            target: _msg19
        }
    }
    Image{
        id: _msg20
        x: 21
        y: 281
        opacity: start_opacity
        source: "./images/eyecatch_msg_20.png"
        PrologueMsgAnim{
            id: _msgAnim20
            target: _msg20
        }
    }
    Image{
        id: _msg21
        x: 207
        y: 158
        opacity: start_opacity
        source: "./images/eyecatch_msg_21.png"
        PrologueMsgAnim{
            id: _msgAnim21
            target: _msg21
        }
    }
    Image{
        id: _msg22
        x: 61
        y: 45
        opacity: start_opacity
        source: "./images/eyecatch_msg_22.png"
        PrologueMsgAnim{
            id: _msgAnim22
            target: _msg22
        }
    }
    Image{
        id: _msg23
        x: 21
        y: 423
        opacity: start_opacity
        source: "./images/eyecatch_msg_23.png"
        PrologueMsgAnim{
            id: _msgAnim23
            target: _msg23
            onFinish: {
                msg_number++;
            }
        }
    }
    Image{
        id: _msg24
        anchors.centerIn: parent
        opacity: start_opacity
        source: "./images/eyecatch_msg_24.png"
        PrologueMsgAnim{
            id: _msgAnim24
            target: _msg24
            onFinish: {
                msg_number = 100;
            }
        }
    }

}
